{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "KlinkenbergEffect.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyPQF0Yxts3qXo8gePMIbcv3",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Divyanshu-ISM/Oil-and-Gas-data-analysis/blob/master/KlinkenbergEffect.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "fu7fbqUrbJ_l",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#Reservoir Engineering with python"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "aotU7t4qb5vs",
        "colab_type": "text"
      },
      "source": [
        "# The Klinkenberg Effect \n",
        "1. k(g) = k(l) + c(1/pm)\n",
        "\n",
        "kg = measured gas permeability\n",
        "pm = mean pressure\n",
        "kL = equivalent liquid permeability, i.e., absolute permeability, k\n",
        "c = slope of the line\n",
        "\n",
        "2. c = b.k(l) = 6.9 kL^(-0.36)\n",
        "\n",
        "3. 6.9*kL^(0.64) + pm*kL - pm*kg = 0\n",
        "\n",
        "# Procedure/Algorithm\n",
        "\n",
        "Equation 3 can be used to calculate the absolute permeability when\n",
        "only one gas permeability measurement (kg) of a core sample is made at\n",
        "pm. This nonlinear equation can be solved iteratively by using the Newton-Raphson iterative methods. The proposed solution method can be\n",
        "conveniently written as\n",
        "\n",
        "k(i+1) = k(i) - f(ki)/f'(ki)\n",
        "\n",
        "where \n",
        "ki = initial guess of the absolute permeability, md\n",
        "ki+1 = new permeability value to be used for the next iteration\n",
        "i = iteration level\n",
        "f(ki) = Equation 3\n",
        "f'(ki) = first-derivative of Equation 3\n",
        "\n",
        "4. f'(ki) = 4.416 ki^(-0.36) + pm \n",
        "\n",
        "The iterative procedure is repeated until convergence is achieved when\n",
        "f(ki) approaches zero or when no changes in the calculated values of ki\n",
        "are observed.\n",
        "\n",
        "(Courtsey- Tarek Ahmed)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "-l0gOH6RgFFp",
        "colab_type": "text"
      },
      "source": [
        "# Example : - \n",
        "\n",
        "The permeability of a core plug is measured by air. Only one measurement is made at a mean pressure of 2.152 psi. The air permeability is\n",
        "46.6 md. Estimate the absolute permeability of the core sample. Compare\n",
        "the result with ***the actual absolute permeability of 23.66 md***."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QifZgBqFd3B0",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 136
        },
        "outputId": "ac07fe73-812f-4e26-c3bc-ea7964271b95"
      },
      "source": [
        "k = input(\"\\nEnter your first guess of absolute permeability kl: \")\n",
        "\n",
        "k = float(k)\n",
        "\n",
        "#f(k= kl) = 6.9kL^(0.64) + pmkL - pm*kg = 0\n",
        "# f'(k) = 4.416 ki^(-0.36) + pm\n",
        "\n",
        "pm  = input(\"\\nEnter Mean Pr. Pm: \")\n",
        "pm = float(pm)\n",
        "\n",
        "kg = input(\"\\nEnter K(air) = kg: \")\n",
        "kg = float(kg)\n",
        "\n",
        "while abs(6.9*(k**0.64) + pm*k - pm*kg) > 0.01:\n",
        "  k = k - (6.9*(k**0.64) + pm*k - pm*kg)/(4.416*(k**(-0.36)) + pm)\n",
        "\n",
        "print(f\"The final value of Perm K is : {k}\")\n"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\n",
            "Enter your first guess of absolute permeability kl: 100\n",
            "\n",
            "Enter Mean Pr. Pm: 2.152\n",
            "\n",
            "Enter K(air) = kg: 46.6\n",
            "The final value of Perm K is : 22.848969848793512\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gXsGVMvgjp_3",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8hxRirsjmJBm",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}